<!doctype html>
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en"> <![endif]-->
<!--[if IE 7]>		<html class="no-js ie7 oldie" lang="en"> <![endif]-->
<!--[if IE 8]>		<html class="no-js ie8 oldie" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

	<title>money.js / fx() - javascript currency conversion library</title>
	<meta name="description" content="money.js is a tiny (1kb) javascript library for real-time currency conversion">
	<meta name="author" content="Open Exchange Rates">

	<meta name="viewport" content="width=device-width,initial-scale=1">
	<link rel="canonical" href="http://openexchangerates.github.com/money.js/" />
	<script type="text/javascript">
		var _gaq = _gaq || [];
		_gaq.push(['_setAccount', 'UA-17884149-3']);
		_gaq.push(['_trackPageview']);
		(function() {
			var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
			ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
			var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
		})();
	</script>

	<link rel="stylesheet" href="demo-resources/style.css">
	<link rel="stylesheet" href="http://openexchangerates.github.io/javascript-sandbox-console/src/sandbox.css">
</head>
<body>
<!--
                   $$$$$
                   $$$$$
           $$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$$$$$$$$$
     $$$$$$$       $$$$$     $$$$$$$
   $$$$$$          $$$$$       $$$$$$$
  $$$$$$           $$$$$        $$$$$$
  $$$$$$           $$$$$
  $$$$$$           $$$$$
   $$$$$$          $$$$$
    $$$$$$$$       $$$$$
      $$$$$$$$$$$$$$$$$$
          $$$$$$$$$$$$$$$$$$$
                 $$$$$$$$$$$$$$$$$
                   $$$$$ $$$$$$$$$$
                   $$$$$       $$$$$$$
                   $$$$$          $$$$$$
                   $$$$$           $$$$$$
$$$$$$$            $$$$$          $$$$$$$
 $$$$$$            $$$$$          $$$$$$$
  $$$$$$$          $$$$$        $$$$$$$$
   $$$$$$$$        $$$$$      $$$$$$$$
      $$$$$$$$$$$$$$$$$$$$$$$$$$$$$
          $$$$$$$$$$$$$$$$$$$$$$
                  $$$$$$$
                   $$$$$
                   $$$$$
-->
	<div id="container">
		<header class="clearfix">
			<h1>money.js<span> / fx()</span></h1>
			<h2>Simple JavaScript currency conversion library with no dependencies, in just over 1 kb.</h2>
			<p>Designed to work seamlessly with data from the <strong><a href="https://openexchangerates.org/" title="Free JSON Currency Conversion Exchange Rates API" target="_blank">Open Exchange Rates API</a></strong> - or any other data source and base currency, with just a few lines of setup. Use standalone, or as a nodeJS/npm or RequireJS (AMD) module.</p>
		</header>

		<div id="main" role="main">

			<pre class="prettyprint lang-js">// From any currency, to any currency:
fx.convert(12.99, {from: "GBP", to: "HKD"});

// Chaining sugar:
fx(1000).from("USD").to("GBP");
fx(1000).to("AED");

// With simple settings and defaults, making this possible:
fx.convert(5318008);
fx(5318008).to("AED");

// Can also be used as a <strong>nodeJS/npm</strong> or <strong>requireJS/AMD</strong> module
var fx = require("money");
require(["money"], function(fx) { /* ... */ });

// Read more below or jump to the <strong><a href="#download" title="download money.js">downloads</a></strong>, <strong><a href="#playground" title="demo sandbox">demo playground</a></strong> or <strong><a href="#documentation" title="money.js documentation">documentation</a></strong>
// maintained by <strong><a href="https://openexchangerates.org" title="Open Exchange Rates currency conversion API" target="_blank">openexchangerates.org</a></strong></pre>

			<p><a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-via="josscrowcroft" data-url="http://openexchangerates.github.io/money.js" data-text="money.js - tiny javascript library for real-time currency conversion" target="_blank">Tweet</a> &nbsp; <g:plusone size="medium"></g:plusone></p>

			<h3>Introduction</h3>
			
			<p>Tired of trying to adapt those 10-year-old <em>"FREE Currency Converter JavaScripts!"</em> into something workable for your enterprise software or shopping cart? <strong>money.js</strong> is a simple library with one function: to convert a money value from any currency to any other currency.</p>

			<p>Read on for some background information, or jump straight to the <strong><a href="#download" title="download money.js">downloads</a></strong>, <strong><a href="#playground" title="demo sandbox">demo playground</a></strong> or <strong><a href="#documentation" title="money.js documentation">documentation</a></strong>.</p>

			<p>In order to perform currency conversion in JavaScript, you'll need a reliable source of real-time exchange rates. <strong><a href="https://openexchangerates.org" title="Free Real-time Exchange Rates JSON API" target="_blank">Open Exchange Rates</a></strong> uses algorithmic blending to calculate a consistently accurate and unbiased set of rates for 165+ world currencies, and provides these via a seamless API to startups, businesses and Fortune 500s, costing 10-20x less than other industry providers (and the only API to offer a <em>Forever Free</em> plan).</p>

			<p>While we recommend this for all users, money.js is not tied to any particular data source - see the <strong><a href="#documentation" title="money.js documentation">documentation</a></strong> to integrate the Open Exchange Rates API data (or any exchange rate data source) with the library in only a few lines of code.</p>

			<p>You only need the conversion rates relative to any single currency, in order to be able to convert values between any other two currencies; <strong>money.js</strong> does it all for you.</p>


			<h3 id="download">Downloads</h3>
			<p>These links always point to the latest stable version of money.js:</p>

			<h4>&raquo; &nbsp;<strong><a href="http://openexchangerates.github.io/money.js/money.js" title="money.js (development, uncompressed)" target="_blank">money.js</a></strong> <span>development version (4.3 kb)</h4>
			<h4>&raquo; &nbsp;<strong><a href="http://openexchangerates.github.io/money.js/money.min.js" title="money.min.js (production, minified)" target="_blank">money.min.js</a></strong> <span>production/minified version (1.1 kb)</h4>
			<p>There are more download options available on the GitHub repository, at <strong><a href="https://github.com/openexchangerates/money.js/" title="openexchangerates/money.js on GitHub">openexchangerates/money.js</a></strong>.</p>


			<h3 id="playground">Demo Playground</h3>

			<p>You can use this JavaScript Sandbox to kick the tires and play around with money.js. It's running in a separate (sandboxed) scope, but you have access to jQuery (<code>$</code>), underscore (<code>_</code>), <a href="http://openexchangerates.github.io/accounting.js/" title="accounting.js - JavaScript number and money formatting library">accounting.js</a> (<code>accounting</code>) and money.js (<code>fx</code>).</p>

			<p>You can use <code>:load <em>script.js</em></code> to load extra libraries, or try <code>:help</code> if stuck.</p>
			<p>Exchange rates should be set up already (defaults = <code>from: "USD"</code>, <code>to: "GBP"</code>) but if not, try refreshing the page. There are some sample commands to try out below.</p>


			<!-- JS Sandbox Console [http://openexchangerates.github.io/javascript-sandbox-console/] -->
			<div id="sandbox">sandbox console loading...</div>


			<h5>Some sample commands to get you started:</h5>
			<p id="sample-commands"></p>

			<p><em>Interested in putting the sandbox on your JavaScript library homepage? It's on GitHub at <strong><a href="http://openexchangerates.github.io/javascript-sandbox-console/" title="JS Sandbox Console" target="_blank">openexchangerates/javascript-sandbox-console</a></strong>.</em></p>

			<h3 id="documentation">Documentation</h3>

			<ul>
				<li><strong><a href="#basic-install" title="">Basic installation</a></strong></li>
				<li><strong><a href="#fx.rates" title="">Setting up exchange rates with fx.rates</a></strong></li>
				<li><strong><a href="#fx.settings-fxSetup" title="">fx.settings</a></strong></li>
				<li><strong><a href="#fx.convert" title="">fx.convert()</a></strong></li>
				<li><strong><a href="#fx.noConflict" title="">fx.noConflict()</a></strong></li>
				<li><strong><a href="#chaining-fx" title="">Chaining with fx(val)</a></strong></li>
				<li><strong><a href="#accounting.js" title="">Usage with 'accounting.js'</a></strong></li>
				<li><strong><a href="#nodeJS-npm" title="">Usage in nodeJS/npm</a></strong></li>
				<li><strong><a href="#amd-requirejs" title="">Usage as a RequireJS/AMD module</a></strong></li>
			</ul>

			<h4 id="basic-install">Basic Installation</h4>

			<p>To use money.js as a standalone library, <strong><a href="#download" title="download money.js">download</a></strong> the minified or development version of money.js, and include it in your HTML page:</p>

			<pre class="prettyprint">&lt;script src=&quot;path/to/money.js&quot;&gt;&lt;/script&gt;</pre>

			<p>You'll need to do one more thing before you can use it, which is:</p>


			<h4 id="fx.rates">Setting up exchange rates with fx.rates</h4>

			<p>To use money.js to convert currencies, you'll need to feed it with some exchange rate data and provide a <code>base</code> currency. (As long as you have exchange rates for every currency relative to one single other ('base') currency, money.js can convert between <em>any other two</em>)</p>

			<p>The library doesn't specify a format for currency names/codes (we recommend sticking to the standard three-letter codes). It also does not mind how accurate they are, or which currency is your <code>base</code> rate.</p>
			<p>Rates are stored in the <code>fx.rates</code> object, while the <code>base</code> currency is stored in <code>fx.base</code>. The base currency must also appear in the rates object. They should like this:</p>

			<pre class="prettyprint">fx.base = "USD";
fx.rates = {
	"EUR" : 0.745101, // eg. 1 USD === 0.745101 EUR
	"GBP" : 0.647710, // etc...
	"HKD" : 7.781919,
	"USD" : 1,        // always include the base rate (1:1)
	/* etc */
}</pre>
			<p>You can include as many or as few currencies as you need, and the rates can be approximate, historical or just plain wrong (though we recommend sticking with up-to-date, accurate data from a <strong><a href="https://openexchangerates.org" title="Exchange Rates JSON API, free currency data" target="_blank">reliable exchange rates API</a></strong>.)</p>
			<p>Always include the <code>base</code> rate (the currency code from <code>fx.base</code>) in <code>fx.rates</code> object, for example <code>"USD" : 1</code>, so that money.js can use it for calculation.</p>

			<p>The latest rates from the <strong><a href="https://openexchangerates.org" title="Exchange Rates JSON API, free currency data" target="_blank">Open Exchange Rates API</a></strong> are delivered as JSON in the required object format, ready to feed into money.js directly. You'll need to <strong><a href="https://openexchangerates.org" title="Open Exchange Rates Free App ID Sign-up" target="_blank">sign up</a></strong> for an App ID, and you can choose whichever option you need (there is a generous <em>Forever Free</em> plan.)</p>
			<p>Using the Open Exchange Rates API as an example, here we load them in via AJAX using jQuery:</p>
			<pre class="prettyprint lang-js">&lt;script type=&quot;text/javascript&quot;&gt;
    // Load exchange rates data via AJAX:
    $.getJSON(
    	// NB: using Open Exchange Rates here, but you can use any source!
        'https://openexchangerates.org/api/latest.json?app_id=<em>[YOUR APP ID]</em>',
        function(data) {
            // Check money.js has finished loading:
            if ( typeof fx !== "undefined" && fx.rates ) {
                fx.rates = data.rates;
                fx.base = data.base;
            } else {
                // If not, apply to fxSetup global:
                var fxSetup = {
                    rates : data.rates,
                    base : data.base
                }
            }
        }
    );
&lt;/script&gt;</pre>
			<p>You'll need to wait until the AJAX request has completed before you can begin processing conversions. You may also wish to cache approximate/historical rates on your server and bootstrap them inline into the HTML as a backup.</p>

			<p>If bootstrapping rates into your HTML page directly, they would need to come after the script is loaded and look like this:</p>
			<pre class="prettyprint lang-js">&lt;script&gt;
    fx.rates = {
    	GBP: 0.6,
    	USD: 1
    };
    fx.base = USD;
&lt;/script&gt;';</pre>

			<p>There are more examples and methods of grabbing the latest (and historical) data, for all the most common languages and frameworks, is the <strong><a href="https://openexchangerates.org" title="Open Exchange Rates - Free JSON Currency Conversion" target="_blank">Open Exchange Rates</a></strong> documentation.</p>

			<p>Whichever API or data source you use, make sure that there is a <code>base</code> currency specified and that the exchange rates are in the object format shown above.</p>


			<h4 id="fx.settings-fxSetup">fx.settings and fxSetup</h4>

			<p>Use <code>fx.settings</code> to set default <code>from</code> and <code>to</code> currencies (optional) after the library has loaded. If you want or need to set these before the library has loaded, create a global object called <code>fxSetup</code>, with the same properties:</p>
			<pre class="prettyprint">// Using `fx.settings` (must be after loading the library)
fx.settings = {
	from : "GBP",
	to : "AED"
};

// Using `fxSetup` (must be before loading the library; see note)
var fxSetup = {
	from : "GBP",
	to : "AED"
};</pre>
			<p><strong>Note about using fxSetup:</strong> If using <code>fxSetup</code>, the variable needs to be available to the library (in scope) - use <code>window.fxSetup</code> if needed. Also note that the fxSetup method won't work if using money.js as an AMD / CommonJS module, because it won't have access to outside variables (use <code>fx.settings</code> for such cases).</p>
			<p>You can also use <code>fxSetup</code> to load in the exchange rates and <code>base</code> currency before loading the library, like so:</p>
			<pre class="prettyprint">// Adding exchange rates and base currency to `fxSetup`:
var fxSetup = {
	from : "GBP",
	to : "AED",
	base : "USD",
	rates : {
		"AED" : 3.672905
		/* etc. */
	}
};</pre>

			<h4 id="fx.convert">fx.convert(val, <em>[opts]</em>)</h4>

			<p>The basic function of the library - converts a value from one currency to another. Uses the default <code>from</code> and <code>to</code> currencies in <code>fx.settings</code>, or those given in <code>opts</code>:</p>
			<pre class="prettyprint">// Using defaults:
fx.settings = { from: "USD", to: "GBP" };
fx.convert(1000); // 647.71034

// With options:
fx.convert(1000, {to: "HKD"}); // 7781.91949 (default `from` currency)
fx.convert(1000, {from: "GBP", to: "HKD"}); // 12014.50549</pre>
			<p><code>fx.convert</code> can convert from any currency to any currency, provided they're both in the <code>fx.rates</code> object. For example, if all rates are relative to USD (1:1), and you have the rate for <code>USD:GBP</code> and <code>USD:HKD</code>, you can specify <code>{from: "GBP", to: "HKD"}</code> - money.js will calculate the relative rate between the two currencies.</p>

			<h5>Currency names</h5>
			<p>Currency names directly reference entries in the <code>fx.rates</code> object, so you're not limited to using the standard 3-letter currency codes. If your exchange rates data source provides pounds (&pound;) as <code>"British Pounds Sterling"</code>, and you pass this directly into the <code>rates</code> object, you could use this instead of <code>"GBP"</code>.</p>
			<p>If you pass in a currency in <code>from</code> or <code>to</code> for which you don't have an exchange rate, money.js <strong>will throw an error</strong> to let you know that the rate wasn't found.</p>

			<h5>Pro Tip:</h5>
			<p>We recommend informing your users that exchange rates and currency conversion are for informational purposes only.</p>


			<h4 id="fx.noConflict">fx.noConflict() <span>available in standalone mode (not AMD/CJS)</span></h4>

			<p>The library's reference - <code>fx</code> - is a fairly common namespace (think animation), which may clash with other scripts. For this case, money.js stores a reference to the previous global value of <code>fx</code>, if any, in case you need to restore it.</p>
			<p>If you're using another library that creates a global <code>fx</code> object or function, you can use <code>fx.noConflict</code> to restore that library's original value and also assign the money.js library object to another variable. For example:</p>
			<pre class="prettyprint">// Some other `fx` library:
var fx = someOtherFxLibrary;

// Assign the money.js library to a global <code>money</code> object:
var money = fx.noConflict();

// `fx` is now back to whatever it was before money.js was loaded, and you
// can use the library via the `money` reference, like so:
money.convert(5318008);
money.settings.from = "JPY";
money(5318008).to("HKD");</pre>

			<h4 id="chaining-fx">Chaining with <code>fx(val)</code></h4>

			<p>money.js provides basic 'chaining' (i.e. connecting method calls together, with each acting on the value returned by the previous.)</p>
			<p>This allows a more expressive, human-readable way of writing code, while the underlying functions are exactly the same. The methods are as follows:</p>

			<h5>fx() <span>returns a 'wrapped' fx object with a value ready for chaining (does not perform any conversion)</span></h5>
			<pre class="prettyprint">fx(16288) // (fxWrapper)

// NB: if parameter is a currency string, fx() will attempt to parse it to extract the
// `from` currency and `value` - so this is the same as the following example:
fx("$16288 HKD") // (fxWrapper)</pre>

			<h5>.from() <span>returns a wrapped fx object, with the value converted from default <code>base</code> to <code>from</code> currency, and ready for conversion to another:</span></h5>
			<pre class="prettyprint">fx(16288).from("HKD") // (fxWrapper)</pre>

			<h5>.to() <span>takes a wrapped fx object (as above) and converts the value to target currency:</span></h5>
			<pre class="prettyprint">fx(16288).to("GBP"); // 10549.906083 (uses default `from` currency)
fx(16288).from("AED").to("GBP"); // 2872.359629</pre>

			<h5>.convert() <span>takes a wrapped fx object and performs <code>fx.convert(val, [opts])</code> on it:</span></h5>
			<pre class="prettyprint">fx(16288).convert(); // uses default `from` / `to` currencies
fx(16288).convert({ from:"HKD", to:"GBP" }); // 1355.694581</pre>


			<h4 id="accounting.js">Integration with accounting.js</h4>

			<p>money.js works great with <strong><a href="http://openexchangerates.github.io/accounting.js" title="accounting.js - format money and numbers in javascript" target="_blank">accounting.js</a></strong> - a standalone JavaScript library that provides reliable localisation and formatting of money and currency. A few examples:</p>
			<pre class="prettyprint">var value = accounting.unformat(someNumber); // clean up number (eg. user input)
var target = "GBP"; // or some user input
var convertedValue = fx(value).from("USD").to(target);

accounting.formatMoney(convertedValue, {
	symbol: target,
	format: "%v %s"
}); // eg. "53,180.08 GBP"</pre>
			<p>This is a good idea when you're displaying currencies - values converted through money.js may have high precision (eg. 12 decimal places) depending on the rates and input value. <strong><a href="http://openexchangerates.github.io/accounting.js" title="accounting.js - format money and numbers in javascript" target="_blank">accounting.js</a></strong> takes care of all the formatting for you, and also correctly rounds values as currency, as shown below with the <code>toFixed()</code> method:</p>
			<pre class="prettyprint">// accounting.toFixed() is a replacement for (Number).toFixed():
(0.615).toFixed(2);           // "0.61" &lt;== standard JavaScript
accounting.toFixed(0.615, 2); // "0.62" &lt;== better</pre>


			<h4 id="nodeJS-npm">Usage in nodeJS / npm</h4>

			<p>money.js can easily be used inside nodeJS or any other module loader:</p>
			<pre class="prettyprint">var fx = require("/path/to/money");
// Now load in your exchange rates and create `fx.settings` if needed</pre>

			<p>We recommend the <strong><a target="_blank" href="http://openexchangerates.github.io/npm-exchange-rates" title="nodeJS npm exchange rates module">exchange-rates</a></strong> npm module to make loading rates quick and easy.</p>

			<p>You may also install the module via <code>npm install money</code> and reference it like this:</p>
			<pre class="prettyprint">var fx = require("money");</pre>


			<h4 id="amd-requirejs">Usage as a RequireJS/AMD module</h4>

			<p>money.js exposes itself as an <acronym title="Asynchronous Module Definition">AMD</acronym> module, for script loaders such as <strong><a href="http://requirejs.org/" title="JavaScript file and AMD module loader" target="_blank">RequireJS</a></strong>:</p>
			<pre class="prettyprint">// Usage as a dependency:
require(["path/to/money"], function(fx) {
	// Now you have a well-scoped `fx` object to use
	fx.convert(5318008);
});</pre>
			<p>You'll need to set up money.js inside the callback function, with <code>fx.rates</code>, <code>fx.base</code> and (optionally) <code>fx.settings</code> - once those are set up, they'll also be set up anywhere else you use <code>fx</code>.</p>


			<h3>Summary</h3>
			<p>That's all you need to know to get started. Summary: use <code>fx.rates</code> and <code>fx.base</code> for setup. Your basic function is <code>fx.convert(val, <em>[opts]</em>)</code>, which can be written like this: <code>fx(val).from("USD").to("GBP")</code> or in several other ways.</p>

			<h3>Links</h3>

			<p>money.js is open source and maintained by <strong><a href="https://openexchangerates.org" title="Open Exchange Rates free currency data API" target="_blank">Open Exchange Rates</a></strong> - the lightweight currency data API for developers, startups and Fortune 500s.</p>
			<p>Feedback, support or questions? <strong><a href="mailto:info@openexchangerates.org" title="Contact Open Exchange Rates">Contact Open Exchange Rates</a></strong> for guidance.</p>
			<p>Bugs, issues, suggestions or contributions? Please <strong><a href="https://github.com/openexchangerates/money.js" title="money.js Github repository">post them here</a></strong>.</p>
			<p>money.js works great with <strong><a href="http://openexchangerates.github.io/accounting.js" title="accounting.js - format money and numbers in javascript" target="_blank">accounting.js</a></strong> - the tiny standalone JavaScript number and currency formatting library, for web & nodeJS</p>

			<br />
			<hr />
			<p><a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-via="josscrowcroft" data-url="http://openexchangerates.github.io/money.js" data-text="money.js - tiny javascript library for real-time currency conversion">Tweet</a> &nbsp; <g:plusone size="medium"></g:plusone></p>

		</div>
	</div>


	<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
	<script>window.jQuery || document.write('<script src="demo-resources/js/libs/jquery-1.6.2.min.js"><\/script>')</script>

	<script src="money.js"></script>


	<script src="demo-resources/js/prettify.js"></script>

	<script type="text/javascript">
		$.ajax({
			url: 'https://openexchangerates.org/api/latest.json?app_id=temporary-1ba057ca38e2d94fe54',
			dataType: 'jsonp',
			error: function() {
				console.log("An error! Please contact info@openexchangerates.org");
			},
			success: function(data) {
				fx.rates = data.rates;
				fx.base = data.base;

				fx.settings = {
					from: "USD",
					to: "GBP"
				}

				setTimeout(function() {
					sandbox.model.iframeEval('fx.settings = { from : "USD", to : "GBP" }; fx.base = "USD"; fx.rates = ' + JSON.stringify(fx.rates) + '; ');
				}, (typeof sandbox !== "undefined") ? 0 : 1000);
			}
		});

		prettyPrint();
	</script>


	<!-- JS sandbox console [http://openexchangerates.github.io/javascript-sandbox-console/] -->

	<!-- The sandbox template: -->
	<script type="text/template" id="tplSandbox">
		<pre class="output"></pre>
		<div class="input">
			<textarea rows="1" placeholder="<%= placeholder %>"></textarea>
		</div>
	</script>

	<!-- The command/result template (NB whitespace/line breaks matter inside <pre> tag): -->
	<script type="text/template" id="tplCommand"><% if (! _hidden) { %><span class="command"><%= command %></span>
<span class="prefix"><%= this.resultPrefix %></span><span class="<%= _class %>"><%= result %></span>
<% } %></script>

	<script src="http://openexchangerates.github.io/javascript-sandbox-console/src/libs/underscore.min.js"></script>
	<script src="http://openexchangerates.github.io/javascript-sandbox-console/src/libs/backbone.min.js"></script>
	<script src="http://openexchangerates.github.io/javascript-sandbox-console/src/libs/backbone-localStorage.min.js"></script>
	<script src="http://openexchangerates.github.io/javascript-sandbox-console/src/sandbox-console.js"></script>
	<script type="text/javascript">
		jQuery(document).ready(function($) {
			// Create the sandbox:
			window.sandbox = new Sandbox.View({
				el : $('#sandbox'),
				model : new Sandbox.Model({ iframe : true, maxHistory : 0 })
			});

			sandbox.model.load("demo-resources/js/libs/jquery-1.6.2.min.js");
			sandbox.model.load("demo-resources/js/libs/accounting-min.js");
			sandbox.model.load("money.js");

			var sampleCommands = [
				["convert a simple value", "fx.convert(5318008);"],
				["basic method chaining", "fx(1000).from('GBP').to('JPY');"],
				["view the exchange rates", "JSON.stringify(fx.rates,0,2)"],
				["get the rate from GBP to AED", "fx.convert(1, {from: 'GBP', to: 'AED'})"],
				["set the default from/to currencies", "fx.settings = {from : 'GBP', to : 'EUR'};"]
			];
			_.each(sampleCommands, function(cmd, i, list) {
				$('<strong><a href="">' + cmd[0] + '</a></strong>').appendTo('#sample-commands').click(function() {
					sandbox.setValue(cmd[1]);
					return false;
				}).after(i < (list.length - 1) ? "&nbsp; &bull; &nbsp;" : "");
			});
		});


		// twitter:
		(function(d, t) {
			var g = d.createElement(t),
				s = d.getElementsByTagName(t)[0];
			g.async = true;
			g.src = 'http://platform.twitter.com/widgets.js';
			s.parentNode.insertBefore(g, s);
		})(document, 'script');

		// google plus:
		window.___gcfg = {lang: 'en-GB'};
		(function() {
			var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
			po.src = 'https://apis.google.com/js/plusone.js';
			var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
		})();
	</script>


	<!--[if lt IE 7 ]>
		<script src="//ajax.googleapis.com/ajax/libs/chrome-frame/1.0.3/CFInstall.min.js"></script>
		<script>window.attachEvent('onload',function(){CFInstall.check({mode:'overlay'})})</script>
	<![endif]-->

</body>
</html>
